package com.sat.common.utils.logger;


/**
 * Created by Single on 2018/3/15.
 */
public class LogUtil {

    static AbsLogger mLogger;

    public static void init(LoggerConfig config) {
        mLogger = new LoggerImpl(config);
    }

    public static void setLogger(AbsLogger absLogger) {
        mLogger = absLogger;
    }

    public static AbsLogger getLogger() {
        return mLogger;
    }

    public static void d(String message, Object... args) {
        checkLogger();
        mLogger.d(message, args);
    }

    public static void d(Object object) {
        checkLogger();
        mLogger.d(object);
    }

    public static void e(String message, Object... args) {
        checkLogger();
        mLogger.e(message, args);
    }

    public static void i(String message, Object... args) {
        checkLogger();
        mLogger.i(message, args);
    }

    public static void v(String message, Object... args) {
        checkLogger();
        mLogger.v(message, args);
    }

    public static void w(String message, Object... args) {

        checkLogger();
        mLogger.w(message, args);
    }

    public static void json(String json) {
        checkLogger();
        mLogger.json(json);
    }

    public static void xml(String xml) {
        checkLogger();
        mLogger.xml(xml);
    }

    public static ILogger tag(String tag) {
        checkLogger();
        return mLogger.tag(tag);
    }

    private static void checkLogger() {
        if (mLogger == null) {
            throw new RuntimeException("You must be call method init or setLogger");
        }
    }
}
